import { fileURLToPath, URL } from "node:url";

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";

import Components from 'unplugin-vue-components/vite';
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers';

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue(), Components({
    resolvers: [
      AntDesignVueResolver({
        importStyle: false, // css in js
      }),
    ],
  })],
  base: "./",
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
    },
  },
  server: {
    host: '0.0.0.0',
    proxy: {
      '/loginn': {
        // target: 'http://10.8.17.70:5550', //代理接口
        target: 'http://10.10.12.61:5550', //代理接口
        // target: 'http://10.20.4.43:39001', //代理接口
        // target: 'http://10.10.6.180:31077', //代理接口
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/loginn/, '')
      },
      // 设置接口代理地址【】MeltingMaterialTemp
      '/api': {
        // target: 'http://10.20.4.43:10050', //代理接口
        target: 'http://10.10.12.61:5555', //代理接口
        // target: 'http://10.10.6.180:30113', //代理接口
        // target: 'http://10.10.6.180:31177', //代理接口
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      },
      '/sap': {
        target: 'http://10.20.2.45:30001', //代理接口
        // target: 'http://10.10.6.180:30113', //代理接口
        // target: 'http://10.10.6.180:31177', //代理接口
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/sap/, '')
      },
      '/file': {
        target: 'http://10.10.12.61:5557', //代理接口
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/file/, '')
      },
      '/speak': {
        target: 'http://10.10.12.61:5559', //代理接口
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/speak/, '')
      },
    }
  },

});
